/**
 * amis v6.13.0
 * build time: 2025-08-12
 * Copyright 2018-2025 baidu
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _ListMenu = require('amis-ui/lib/components/ListMenu');
var _PopUp = require('amis-ui/lib/components/PopUp');
var _Spinner = require('amis-ui/lib/components/Spinner');
var _ResultBox = require('amis-ui/lib/components/ResultBox');
var tslib = require('tslib');
var React = require('react');
var amisCore = require('amis-core');
var Downshift = require('downshift');
var find = require('lodash/find');
var isInteger = require('lodash/isInteger');
var unionWith = require('lodash/unionWith');
var compact = require('lodash/compact');
var uniq = require('lodash/uniq');
var ReactDOM = require('react-dom');
var StaticHoc = require('./StaticHoc.js');
var matchSorter = require('match-sorter');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _ListMenu__default = /*#__PURE__*/_interopDefaultLegacy(_ListMenu);
var _PopUp__default = /*#__PURE__*/_interopDefaultLegacy(_PopUp);
var _Spinner__default = /*#__PURE__*/_interopDefaultLegacy(_Spinner);
var _ResultBox__default = /*#__PURE__*/_interopDefaultLegacy(_ResultBox);
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
var Downshift__default = /*#__PURE__*/_interopDefaultLegacy(Downshift);
var find__default = /*#__PURE__*/_interopDefaultLegacy(find);
var isInteger__default = /*#__PURE__*/_interopDefaultLegacy(isInteger);
var unionWith__default = /*#__PURE__*/_interopDefaultLegacy(unionWith);
var compact__default = /*#__PURE__*/_interopDefaultLegacy(compact);
var uniq__default = /*#__PURE__*/_interopDefaultLegacy(uniq);

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
var _J$F_ = (__react_jsx__["default"] || __react_jsx__).Fragment;


;var TagControl = /** @class */function (_super) {
  tslib.__extends(TagControl, _super);
  function TagControl(props) {
    var _this = _super.call(this, props) || this;
    _this.input = React__default["default"].createRef();
    _this.state = {
      isOpened: false,
      inputValue: '',
      isFocused: false,
      selectedOptions: props.selectedOptions,
      cacheOptions: []
    };
    return _this;
  }
  TagControl.prototype.componentDidUpdate = function (prevProps) {
    var props = this.props;
    if (prevProps.value !== props.value) {
      this.setState({
        inputValue: ''
      });
    }
  };
  TagControl.prototype.doAction = function (action, data, throwErrors) {
    var _a, _b;
    var _c = this.props,
      resetValue = _c.resetValue,
      onChange = _c.onChange,
      formStore = _c.formStore,
      store = _c.store,
      name = _c.name;
    var actionType = action === null || action === void 0 ? void 0 : action.actionType;
    if (actionType === 'clear') {
      onChange === null || onChange === void 0 ? void 0 : onChange('');
    } else if (actionType === 'reset') {
      var pristineVal = (_b = amisCore.getVariable((_a = formStore === null || formStore === void 0 ? void 0 : formStore.pristine) !== null && _a !== void 0 ? _a : store === null || store === void 0 ? void 0 : store.pristine, name)) !== null && _b !== void 0 ? _b : resetValue;
      onChange === null || onChange === void 0 ? void 0 : onChange(pristineVal !== null && pristineVal !== void 0 ? pristineVal : '');
    }
  };
  TagControl.prototype.dispatchEvent = function (eventName, eventData) {
    if (eventData === void 0) {
      eventData = {};
    }
    return tslib.__awaiter(this, void 0, void 0, function () {
      var _a, dispatchEvent, options, rendererEvent;
      return tslib.__generator(this, function (_b) {
        switch (_b.label) {
          case 0:
            _a = this.props, dispatchEvent = _a.dispatchEvent, options = _a.options;
            return [4 /*yield*/, dispatchEvent(eventName, amisCore.resolveEventData(this.props, tslib.__assign({
              options: options,
              items: options
            }, eventData)))];
          case 1:
            rendererEvent = _b.sent();
            // 返回阻塞标识
            return [2 /*return*/, !!(rendererEvent === null || rendererEvent === void 0 ? void 0 : rendererEvent.prevented)];
        }
      });
    });
  };
  /** 处理输入的内容 */
  TagControl.prototype.normalizeInputValue = function (inputValue) {
    var _a = this.props,
      enableBatchAdd = _a.enableBatchAdd,
      separator = _a.separator,
      valueField = _a.valueField,
      labelField = _a.labelField,
      delimiter = _a.delimiter;
    var batchValues = [];
    if (enableBatchAdd && separator && typeof separator === 'string') {
      batchValues = inputValue.split(separator);
    } else {
      var inputValueArr = uniq__default["default"](compact__default["default"](inputValue.split(delimiter || ',')));
      batchValues.push.apply(batchValues, tslib.__spreadArray([], tslib.__read(inputValueArr), false));
    }
    return batchValues.filter(Boolean).map(function (item) {
      var _a;
      return _a = {}, _a["".concat(valueField || 'value')] = item, _a["".concat(labelField || 'label')] = item, _a;
    });
  };
  TagControl.prototype.normalizeOptions = function (options) {
    var _a = this.props,
      joinValues = _a.joinValues,
      extractValue = _a.extractValue,
      delimiter = _a.delimiter,
      valueField = _a.valueField;
    return joinValues ? options.map(function (item) {
      return item[valueField || 'value'];
    }).join(delimiter || ',') : extractValue ? options.map(function (item) {
      return item[valueField || 'value'];
    }) : options;
  };
  /** 输入的内容和存量的内容合并，过滤掉value值相同的 */
  TagControl.prototype.normalizeMergedValue = function (inputValue, normalized) {
    if (normalized === void 0) {
      normalized = true;
    }
    var _a = this.props,
      selectedOptions = _a.selectedOptions,
      valueField = _a.valueField;
    var options = unionWith__default["default"](selectedOptions.concat(), this.normalizeInputValue(inputValue), function (origin, input) {
      return origin[valueField || 'value'] === input[valueField || 'value'];
    });
    return normalized ? this.normalizeOptions(options) : options;
  };
  TagControl.prototype.validateInputValue = function (inputValue) {
    var _a = this.props,
      max = _a.max,
      maxTagLength = _a.maxTagLength,
      enableBatchAdd = _a.enableBatchAdd,
      separator = _a.separator,
      onInputValidateFailed = _a.onInputValidateFailed,
      valueField = _a.valueField;
    var normalizedValue = this.normalizeMergedValue(inputValue, false);
    if (max != null && isInteger__default["default"](max) && normalizedValue.length > max) {
      onInputValidateFailed === null || onInputValidateFailed === void 0 ? void 0 : onInputValidateFailed(normalizedValue.map(function (item) {
        return item[valueField || 'value'];
      }), 'max');
      return false;
    }
    var addedValues = this.normalizeInputValue(inputValue);
    if (maxTagLength != null && isInteger__default["default"](maxTagLength) && addedValues.some(function (item) {
      return item[valueField || 'value'].length > maxTagLength;
    })) {
      onInputValidateFailed === null || onInputValidateFailed === void 0 ? void 0 : onInputValidateFailed(addedValues.map(function (item) {
        return item[valueField || 'value'];
      }), 'maxLength');
      return false;
    }
    return true;
  };
  TagControl.prototype.getValue = function (type, option, selectedOptions) {
    if (type === void 0) {
      type = 'normal';
    }
    if (option === void 0) {
      option = {};
    }
    var _a = this.props,
      joinValues = _a.joinValues,
      extractValue = _a.extractValue,
      delimiter = _a.delimiter,
      valueField = _a.valueField;
    selectedOptions = selectedOptions ? selectedOptions : this.props.selectedOptions;
    var newValue = selectedOptions.concat();
    if (type === 'push') {
      newValue.push(option);
    } else if (type === 'pop') {
      newValue.pop();
    }
    return joinValues ? newValue.map(function (item) {
      return item[valueField || 'value'];
    }).join(delimiter || ',') : extractValue ? newValue.map(function (item) {
      return item[valueField || 'value'];
    }) : newValue;
  };
  TagControl.prototype.addItem = function (option) {
    return tslib.__awaiter(this, void 0, void 0, function () {
      var _a, selectedOptions, onChange, valueField, newValue, newValueRes, isPrevented;
      return tslib.__generator(this, function (_b) {
        switch (_b.label) {
          case 0:
            if (this.isReachMax()) {
              return [2 /*return*/];
            }
            _a = this.props, selectedOptions = _a.selectedOptions, onChange = _a.onChange, valueField = _a.valueField;
            newValue = selectedOptions.concat();
            if (find__default["default"](newValue, function (item) {
              return item[valueField || 'value'] == option[valueField || 'value'];
            })) {
              return [2 /*return*/];
            }
            newValueRes = this.getValue('push', option);
            return [4 /*yield*/, this.dispatchEvent('change', {
              value: newValueRes,
              selectedItems: selectedOptions.concat(option)
            })];
          case 1:
            isPrevented = _b.sent();
            isPrevented || onChange(newValueRes);
            return [2 /*return*/];
        }
      });
    });
  };
  // 移动端特殊处理
  TagControl.prototype.addItem2 = function (option) {
    var _a = this.props,
      mobileUI = _a.mobileUI,
      _b = _a.valueField,
      valueField = _b === void 0 ? 'value' : _b;
    if (mobileUI) {
      var selectedOptions = this.state.selectedOptions.concat();
      var index = selectedOptions.findIndex(function (item) {
        return item[valueField] === option[valueField];
      });
      if (~index) {
        selectedOptions.splice(index, 1);
      } else if (!this.isReachMaxFromState()) {
        selectedOptions.push(option);
      }
      this.setState({
        selectedOptions: selectedOptions
      });
    }
  };
  // 手机端校验
  TagControl.prototype.isExist = function (inputValue) {
    var _a = this.props,
      options = _a.options,
      _b = _a.valueField,
      valueField = _b === void 0 ? 'value' : _b;
    var cacheOptions = this.state.cacheOptions;
    return options.some(function (item) {
      return item[valueField] === inputValue;
    }) || cacheOptions.some(function (item) {
      return item[valueField] === inputValue;
    });
  };
  TagControl.prototype.addSelection = function () {
    var inputValue = this.state.inputValue;
    var maxTagLength = this.props.maxTagLength;
    var selectedOptions = this.state.selectedOptions.slice();
    var cacheOptions = this.state.cacheOptions.slice();
    if (maxTagLength !== undefined) {
      inputValue = inputValue.trim();
      inputValue = inputValue.slice(0, maxTagLength);
    }
    if (this.isExist(inputValue)) {
      return;
    }
    if (inputValue && !this.isReachMaxFromState()) {
      var addedValues = this.normalizeInputValue(inputValue);
      selectedOptions.push(addedValues[0]);
      cacheOptions.push(addedValues[0]);
      this.setState({
        inputValue: '',
        selectedOptions: selectedOptions,
        cacheOptions: cacheOptions
      });
    }
  };
  TagControl.prototype.onConfirm = function () {
    return tslib.__awaiter(this, void 0, void 0, function () {
      var selectedOptions, onChange, newValueRes, isPrevented;
      return tslib.__generator(this, function (_a) {
        switch (_a.label) {
          case 0:
            selectedOptions = this.state.selectedOptions;
            onChange = this.props.onChange;
            newValueRes = this.getValue('normal', {}, selectedOptions);
            return [4 /*yield*/, this.dispatchEvent('change', {
              value: newValueRes,
              selectedItems: selectedOptions
            })];
          case 1:
            isPrevented = _a.sent();
            isPrevented || onChange(newValueRes);
            this.close();
            return [2 /*return*/];
        }
      });
    });
  };
  TagControl.prototype.handleFocus = function (e) {
    var _a, _b;
    return tslib.__awaiter(this, void 0, void 0, function () {
      var newValueRes, isPrevented;
      return tslib.__generator(this, function (_c) {
        switch (_c.label) {
          case 0:
            this.setState({
              isFocused: true,
              isOpened: true,
              selectedOptions: this.props.selectedOptions
            });
            newValueRes = this.getValue('normal');
            return [4 /*yield*/, this.dispatchEvent('focus', {
              value: newValueRes,
              selectedItems: this.props.selectedOptions
            })];
          case 1:
            isPrevented = _c.sent();
            isPrevented || ((_b = (_a = this.props).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, e));
            return [2 /*return*/];
        }
      });
    });
  };
  TagControl.prototype.handleBlur = function (e) {
    var _a, _b;
    return tslib.__awaiter(this, void 0, void 0, function () {
      var _c, selectedOptions, onChange, mobileUI, options, value, newValueRes, isPrevented;
      return tslib.__generator(this, function (_d) {
        switch (_d.label) {
          case 0:
            _c = this.props, selectedOptions = _c.selectedOptions, onChange = _c.onChange, mobileUI = _c.mobileUI, options = _c.options;
            if (mobileUI && options.length) {
              return [2 /*return*/];
            }
            value = this.state.inputValue.trim();
            if (!this.validateInputValue(value)) {
              this.setState({
                isFocused: false,
                isOpened: false
              });
              return [2 /*return*/];
            }
            newValueRes = this.normalizeMergedValue(value);
            return [4 /*yield*/, this.dispatchEvent('blur', {
              value: newValueRes,
              selectedItems: selectedOptions
            })];
          case 1:
            isPrevented = _d.sent();
            isPrevented || ((_b = (_a = this.props).onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, e));
            this.setState({
              isFocused: false,
              isOpened: false,
              inputValue: ''
            }, value ? function () {
              if (selectedOptions.length !== newValueRes.length) {
                onChange === null || onChange === void 0 ? void 0 : onChange(newValueRes);
              }
            } : undefined);
            return [2 /*return*/];
        }
      });
    });
  };
  TagControl.prototype.close = function () {
    this.setState({
      isOpened: false
    });
  };
  TagControl.prototype.handleInputChange = function (text) {
    this.setState({
      inputValue: text
    });
  };
  TagControl.prototype.handleChange = function (value) {
    return tslib.__awaiter(this, void 0, void 0, function () {
      var _a, joinValues, extractValue, delimiter, valueField, onChange, newValue, isPrevented;
      return tslib.__generator(this, function (_b) {
        switch (_b.label) {
          case 0:
            _a = this.props, joinValues = _a.joinValues, extractValue = _a.extractValue, delimiter = _a.delimiter, valueField = _a.valueField, onChange = _a.onChange;
            newValue = Array.isArray(value) ? value.concat() : [];
            if (joinValues || extractValue) {
              newValue = value.map(function (item) {
                return item[valueField || 'value'];
              });
            }
            if (joinValues) {
              newValue = newValue.join(delimiter || ',');
            }
            return [4 /*yield*/, this.dispatchEvent('change', {
              value: newValue,
              selectedItems: value
            })];
          case 1:
            isPrevented = _b.sent();
            isPrevented || onChange(newValue);
            return [2 /*return*/];
        }
      });
    });
  };
  TagControl.prototype.renderItem = function (item) {
    var labelField = this.props.labelField;
    return "".concat(item[labelField || 'label']);
  };
  TagControl.prototype.handleKeyDown = function (evt) {
    return tslib.__awaiter(this, void 0, void 0, function () {
      var _a, selectedOptions, onChange, delimiter, labelField, valueField, value, selectedItems, newValueRes, isPrevented, newValueRes, isPrevented;
      return tslib.__generator(this, function (_b) {
        switch (_b.label) {
          case 0:
            _a = this.props, selectedOptions = _a.selectedOptions, onChange = _a.onChange, delimiter = _a.delimiter, labelField = _a.labelField, valueField = _a.valueField;
            value = this.state.inputValue.trim();
            selectedItems = selectedOptions.concat(this.normalizeMergedValue(value, false));
            if (!(selectedOptions.length && !value && evt.key == 'Backspace')) return [3 /*break*/, 2];
            newValueRes = this.getValue('pop');
            return [4 /*yield*/, this.dispatchEvent('change', {
              value: newValueRes,
              selectedItems: selectedItems
            })];
          case 1:
            isPrevented = _b.sent();
            isPrevented || onChange(newValueRes);
            return [3 /*break*/, 5];
          case 2:
            if (!(value && (evt.key === 'Enter' || evt.key === delimiter))) return [3 /*break*/, 4];
            evt.preventDefault();
            evt.stopPropagation();
            newValueRes = this.normalizeMergedValue(value);
            return [4 /*yield*/, this.dispatchEvent('change', {
              value: newValueRes,
              selectedItems: selectedItems
            })];
          case 3:
            isPrevented = _b.sent();
            if (!this.validateInputValue(value)) {
              this.setState({
                isFocused: false,
                isOpened: false
              });
              return [2 /*return*/];
            }
            if (!isPrevented && selectedOptions.length !== newValueRes.length) {
              onChange(newValueRes);
            }
            this.setState({
              inputValue: ''
            });
            return [3 /*break*/, 5];
          case 4:
            if (!value && evt.key === 'Enter') {
              this.handleBlur(evt);
            }
            _b.label = 5;
          case 5:
            return [2 /*return*/];
        }
      });
    });
  };
  TagControl.prototype.handleOptionChange = function (option) {
    var mobileUI = this.props.mobileUI;
    if (mobileUI) {
      this.addItem2(option);
      return;
    }
    if (this.isReachMax() || !option) {
      return;
    }
    this.addItem(option);
  };
  TagControl.prototype.getTarget = function () {
    return this.input.current;
  };
  TagControl.prototype.getParent = function () {
    return this.input.current && ReactDOM.findDOMNode(this.input.current).parentElement;
  };
  TagControl.prototype.reload = function (subpath, query) {
    var reload = this.props.reloadOptions;
    reload && reload(subpath, query);
  };
  TagControl.prototype.isReachMax = function () {
    var _a = this.props,
      max = _a.max,
      selectedOptions = _a.selectedOptions;
    return max != null && isInteger__default["default"](max) && selectedOptions.length >= max;
  };
  TagControl.prototype.isReachMaxFromState = function () {
    var selectedOptions = this.state.selectedOptions;
    var max = this.props.max;
    return max != null && isInteger__default["default"](max) && selectedOptions.length >= max;
  };
  TagControl.prototype.render = function () {
    var _this = this;
    var _a = this.props,
      className = _a.className,
      style = _a.style,
      cx = _a.classnames,
      disabled = _a.disabled,
      placeholder = _a.placeholder,
      name = _a.name,
      clearable = _a.clearable,
      selectedOptions = _a.selectedOptions,
      loading = _a.loading,
      popOverContainer = _a.popOverContainer,
      dropdown = _a.dropdown,
      options = _a.options,
      optionsTip = _a.optionsTip,
      maxTagCount = _a.maxTagCount,
      overflowTagPopover = _a.overflowTagPopover,
      __ = _a.translate,
      loadingConfig = _a.loadingConfig,
      valueField = _a.valueField,
      env = _a.env,
      mobileUI = _a.mobileUI,
      labelField = _a.labelField,
      testIdBuilder = _a.testIdBuilder;
    var term = this.state.inputValue;
    var finnalOptions = Array.isArray(options) ? amisCore.filterTree(options, function (item, key, level, paths) {
      return item[valueField || 'value'] !== undefined && (mobileUI || !~selectedOptions.indexOf(item)) && (matchSorter.matchSorter([item].concat(paths), term, {
        keys: [labelField || 'label', valueField || 'value'],
        threshold: matchSorter.matchSorter.rankings.CONTAINS
      }).length || Array.isArray(item.children) && !!item.children.length);
    }, 0, true) : [];
    var reachMax = this.isReachMax();
    return _J$X_(Downshift__default["default"], {
      selectedItem: selectedOptions,
      isOpen: mobileUI ? this.state.isOpened : this.state.isFocused,
      inputValue: this.state.inputValue,
      onChange: this.handleOptionChange,
      itemToString: this.renderItem
    }, function (_a) {
      var isOpen = _a.isOpen,
        highlightedIndex = _a.highlightedIndex,
        getItemProps = _a.getItemProps,
        getInputProps = _a.getInputProps;
      return _J$X_("div", {
        className: cx(className, "TagControl")
      }, _J$X_(_ResultBox__default["default"], tslib.__assign({}, getInputProps({
        name: name,
        ref: _this.input,
        placeholder: __(placeholder !== null && placeholder !== void 0 ? placeholder : 'Tag.placeholder'),
        value: _this.state.inputValue,
        onKeyDown: _this.handleKeyDown,
        onFocus: !mobileUI ? _this.handleFocus : undefined,
        onBlur: _this.handleBlur,
        disabled: disabled
      }), {
        onResultClick: mobileUI ? _this.handleFocus : undefined,
        inputPlaceholder: '',
        onChange: _this.handleInputChange,
        className: cx('TagControl-input'),
        result: selectedOptions,
        onResultChange: _this.handleChange,
        itemRender: _this.renderItem,
        clearable: clearable,
        maxTagCount: maxTagCount,
        overflowTagPopover: overflowTagPopover,
        popOverContainer: popOverContainer || env.getModalContainer,
        allowInput: !mobileUI || mobileUI && !(options === null || options === void 0 ? void 0 : options.length),
        mobileUI: mobileUI,
        testIdBuilder: testIdBuilder === null || testIdBuilder === void 0 ? void 0 : testIdBuilder.getChild('resule-box')
      }), loading ? _J$X_(_Spinner__default["default"], {
        loadingConfig: loadingConfig,
        size: "sm"
      }) : undefined), dropdown !== false ? mobileUI ? _J$X_(_PopUp__default["default"], {
        className: cx("Tag-popup"),
        container: mobileUI ? env === null || env === void 0 ? void 0 : env.getModalContainer : popOverContainer || env.getModalContainer,
        isShow: isOpen && !!finnalOptions.length,
        showConfirm: true,
        onConfirm: _this.onConfirm,
        onHide: _this.close
      }, _J$X_("div", null, _J$X_(_ListMenu__default["default"], {
        selectedOptions: selectedOptions,
        mobileUI: mobileUI,
        options: finnalOptions.concat(_this.state.cacheOptions),
        itemRender: _this.renderItem,
        highlightIndex: highlightedIndex,
        getItemProps: function (_a) {
          var item = _a.item,
            index = _a.index;
          return tslib.__assign({}, getItemProps({
            index: index,
            item: item,
            className: cx('ListMenu-item', {
              'is-active': ~(_this.state.selectedOptions.map(function (item) {
                return item[valueField];
              }) || []).indexOf(item[valueField])
            })
          }));
        }
      }), mobileUI && !_this.isReachMaxFromState() ? _J$X_("div", {
        className: cx('ListMenu-add-wrap')
      }, _J$X_(_ResultBox__default["default"], {
        placeholder: __('placeholder.enter') + '...',
        allowInput: true,
        value: _this.state.inputValue,
        mobileUI: mobileUI,
        clearable: true,
        maxTagCount: maxTagCount,
        onChange: function (value) {
          _this.setState({
            inputValue: value
          });
        },
        onBlur: _this.addSelection
      })) : null)) : _J$X_(amisCore.Overlay, {
        container: popOverContainer || _this.getParent,
        target: _this.getTarget,
        placement: 'auto',
        show: isOpen && !!finnalOptions.length
      }, _J$X_(amisCore.PopOver, {
        overlay: true,
        className: cx('TagControl-popover'),
        onHide: _this.close
      }, _J$X_(_ListMenu__default["default"], {
        options: finnalOptions,
        itemRender: _this.renderItem,
        highlightIndex: highlightedIndex,
        testIdBuilder: testIdBuilder === null || testIdBuilder === void 0 ? void 0 : testIdBuilder.getChild('options'),
        getItemProps: function (_a) {
          var item = _a.item,
            index = _a.index;
          return tslib.__assign({}, getItemProps({
            index: index,
            item: item,
            disabled: reachMax || item.disabled,
            className: cx('ListMenu-item', {
              'is-disabled': reachMax
            })
          }));
        }
      }))) :
      // 保留原来的展现方式，不推荐
      _J$X_("div", {
        className: cx('TagControl-sug')
      }, optionsTip ? _J$X_("div", {
        className: cx('TagControl-sugTip')
      }, __(optionsTip)) : null, options.map(function (item, index) {
        return _J$X_("div", {
          className: cx('TagControl-sugItem', {
            'is-disabled': item.disabled || disabled || reachMax
          }),
          key: index,
          onClick: _this.addItem.bind(_this, item)
        }, item.label);
      })));
    });
  };
  TagControl.defaultProps = {
    resetValue: '',
    labelField: 'label',
    valueField: 'value',
    multiple: true,
    placeholder: 'Tag.placeholder',
    optionsTip: 'Tag.tip',
    separator: '-'
  };
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [String, Object]), tslib.__metadata("design:returntype", Promise)], TagControl.prototype, "dispatchEvent", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [String, Object, Array]), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "getValue", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "addSelection", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", Promise)], TagControl.prototype, "onConfirm", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", Promise)], TagControl.prototype, "handleFocus", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", Promise)], TagControl.prototype, "handleBlur", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "close", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [String]), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "handleInputChange", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Array]), tslib.__metadata("design:returntype", Promise)], TagControl.prototype, "handleChange", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", Object)], TagControl.prototype, "renderItem", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", Promise)], TagControl.prototype, "handleKeyDown", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", [Object]), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "handleOptionChange", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "getTarget", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "getParent", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "isReachMax", null);
  tslib.__decorate([amisCore.autobind, tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "isReachMaxFromState", null);
  tslib.__decorate([StaticHoc.supportStatic(), tslib.__metadata("design:type", Function), tslib.__metadata("design:paramtypes", []), tslib.__metadata("design:returntype", void 0)], TagControl.prototype, "render", null);
  return TagControl;
}(React__default["default"].PureComponent);
var TagControlRenderer = /** @class */function (_super) {
  tslib.__extends(TagControlRenderer, _super);
  function TagControlRenderer() {
    return _super !== null && _super.apply(this, arguments) || this;
  }
  TagControlRenderer = tslib.__decorate([amisCore.OptionsControl({
    type: 'input-tag'
  })], TagControlRenderer);
  return TagControlRenderer;
}(TagControl);

exports.TagControlRenderer = TagControlRenderer;
exports["default"] = TagControl;
